﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.Data.OracleClient;
using Xiaov.SmartWeb.Application.SupCan;

namespace Xiaov.SmartWeb.Application.HXZB.Tzfx
{
    public partial class XmlbTree : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string sql = "select pxbm,lbmc from yt_xmlbb";
                DataSet ds = Maticsoft.DBUtility.DbHelperOra.Query(sql);

                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    Response.ContentType = "text/xml";
                    Response.ContentEncoding = Encoding.Default;
                    Response.CacheControl = "no-cache";
                    StringBuilder sbStr = new StringBuilder(); //用来存储下面生成的xml
                    sbStr.Append("<?xml version='1.0' encoding='utf-8'?>");
                    sbStr.Append(@"<TreeList><Properties isTree='true' headerHeight='0'></Properties><cols>                   
                    <Col name='pxbm' isHide='true'></Col>                     
                    <Col name='lbmc' width='200'>类别名称</Col></Cols><Table>");
                    if (ds != null && ds.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            sbStr.Append("<TR><TD>");
                            sbStr.Append(dr["pxbm"]);
                            sbStr.Append("</TD><TD>");
                            sbStr.Append(dr["lbmc"]);
                            sbStr.Append("</TD></TR>");
                        }
                    }
                    sbStr.Append("</Table></TreeList>");
                    Response.Write(sbStr.ToString());
                    Response.End();
                }
            }
        }
    }
}